package org.BUPT.api.controller;

import org.BUPT.Service.FileUploader;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Controller;
import org.springframework.web.bind.annotation.*;
import org.springframework.web.multipart.MultipartFile;

@Controller
@CrossOrigin
public class FrontController {

    @Autowired
    FileUploader fileUploader;
    @GetMapping("/login")
    public String login() {
        return "login/index";
    }
    @GetMapping("/question/list")
    public String list(){
        return "question/list";
    }
    @GetMapping("/question")
    public String detail(){
        return "question/detail";
    }

    @ResponseBody
    @RequestMapping("/saveImage")
    public String saveImage(@RequestParam("image")  MultipartFile image) throws Exception {

        return "{ \"location\" : \""+fileUploader.uploadImage(image)+"\" }";
    }



}
